gdk-win32: Really Implement GdkScreen->is_composited()
authorChun-wei Fan <fanchunwei@src.gnome.org>
Wed, 15 Apr 2015 09:44:55 +0000 (17:44 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Fri, 17 Apr 2015 03:23:53 +0000 (11:23 +0800)
The current GdkScreen->is_composited() is a stub as we were having Windows
XP being supported, which does not support Desktop Window Manager (DWM),
which is used by Windows for composition.

Windows Vista and later support DWM, and it is always enabled on Windows 8/
Server 2012 and later.

Please note that as we are dropping XP support in this cycle, this is the
commit that would say goodbye to Windows XP support for GTK+-3.x, by
linking directly to dwmapi.dll.  This means, we only check whether we are
on Windows 8 or Server 2012 (or later) to see whether we unconditionally
have composition enabled.

https://bugzilla.gnome.org/show_bug.cgi?id=741849

build/win32/vs10/gdk.vcxprojin
build/win32/vs9/gdk.vcprojin
configure.ac
gdk/win32/gdkglobals-win32.c
gdk/win32/gdkmain-win32.c
gdk/win32/gdkprivate-win32.h
gdk/win32/gdkscreen-win32.c

index 35e14a2d1a0e7d95a53063ebf0d51d881422030d..fff2f6da67c5fe4a1fc81721c32a4120cb2c3e60 100644 (file)
       <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>imm32.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>imm32.lib;winmm.lib;ws2_32.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).dll</OutputFile>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).pdb</ProgramDatabaseFile>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>imm32.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>imm32.lib;winmm.lib;ws2_32.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).dll</OutputFile>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).pdb</ProgramDatabaseFile>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>imm32.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>imm32.lib;winmm.lib;ws2_32.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).dll</OutputFile>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).pdb</ProgramDatabaseFile>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>imm32.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>imm32.lib;winmm.lib;ws2_32.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).dll</OutputFile>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).pdb</ProgramDatabaseFile>
index ad33f6ef96bd4ce25850b6c6c58ea09b7ddc48ad..59d17362a3a92961201aeb857710bd809a1de202 100644 (file)
@@ -74,7 +74,7 @@
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="imm32.lib winmm.lib ws2_32.lib"
+                               AdditionalDependencies="imm32.lib winmm.lib ws2_32.lib dwmapi.lib"
                                OutputFile="$(OutDir)\$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).dll"
                                LinkIncremental="1"
                                GenerateDebugInformation="true"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="imm32.lib winmm.lib ws2_32.lib"
+                               AdditionalDependencies="imm32.lib winmm.lib ws2_32.lib dwmapi.lib"
                                OutputFile="$(OutDir)\$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).dll"
                                LinkIncremental="1"
                                GenerateDebugInformation="true"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="imm32.lib winmm.lib ws2_32.lib"
+                               AdditionalDependencies="imm32.lib winmm.lib ws2_32.lib dwmapi.lib"
                                OutputFile="$(OutDir)\$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).dll"
                                LinkIncremental="1"
                                GenerateDebugInformation="true"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="imm32.lib winmm.lib ws2_32.lib"
+                               AdditionalDependencies="imm32.lib winmm.lib ws2_32.lib dwmapi.lib"
                                OutputFile="$(OutDir)\$(GtkDllPrefix)$(ProjectName)$(GtkDllSuffix).dll"
                                LinkIncremental="1"
                                GenerateDebugInformation="true"
index 7dc9c265cba1bf3c1319e71519c33fe2da6cba1c..ba8954c3c8fd5dcabf41cbe1eed9dd5666f0686b 100644 (file)
@@ -375,7 +375,7 @@ if test "$enable_win32_backend" = "yes"; then
   backend_immodules="$backend_immodules,ime"
   GDK_WINDOWING="$GDK_WINDOWING
 #define GDK_WINDOWING_WIN32"
-  GDK_EXTRA_LIBS="$GDK_EXTRA_LIBS -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm"
+  GDK_EXTRA_LIBS="$GDK_EXTRA_LIBS -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi"
   AM_CONDITIONAL(USE_WIN32, true)
   PANGO_PACKAGES="pangowin32 pangocairo"
 else
index 5248a009cfc965ca35db8f6833762d7d954311fc..3d1c17f5d69a625e5ed7cecf3873f049f2b0fa26 100644 (file)
@@ -82,3 +82,5 @@ gboolean        _ignore_destroy_clipboard = FALSE;
 
 HGLOBAL           _delayed_rendering_data = NULL;
 GHashTable       *_format_atom_table = NULL;
+
+gboolean          _is_win8_or_later = FALSE;
index 905c729fab98afe0fd5d12db6abbd44b6078327c..f12c16673bdbd5b62640c165c2d1e4f48ac28ab7 100644 (file)
@@ -130,6 +130,7 @@ _gdk_win32_windowing_init (void)
   _cf_url = RegisterClipboardFormat ("UniformResourceLocatorW");
   _cf_html_format = RegisterClipboardFormat ("HTML Format");
   _cf_text_html = RegisterClipboardFormat ("text/html");
+  _is_win8_or_later = g_win32_check_windows_version (6, 2, 0, G_WIN32_OS_ANY);
 
   _gdk_win32_selection_init ();
 }
index acc3fcac05cfa2874e8a2f646be688959d4047b5..dbb9a7900b37a220118c2fe12bf2d2f02f05d558 100644 (file)
@@ -508,4 +508,6 @@ void _gdk_events_init (void);
 void _gdk_input_init  (GdkDisplay *display);
 void _gdk_input_wintab_init_check (GdkDeviceManager *device_manager);
 
+extern gboolean _is_win8_or_later;
+
 #endif /* __GDK_PRIVATE_WIN32_H__ */
index 8c6fb03400162a9107fa96bea96aa2c3f6846528..4e9cc992b1ac8b0e7d12ad12eef8436ca80dc5dc 100644 (file)
@@ -21,6 +21,8 @@
 #include "gdkscreenprivate.h"
 #include "gdkwin32screen.h"
 
+#include <dwmapi.h>
+
 struct _GdkWin32Screen
 {
   GdkScreen parent_instance;
@@ -195,9 +197,18 @@ gdk_win32_screen_get_window_stack (GdkScreen *screen)
 static gboolean
 gdk_win32_screen_is_composited (GdkScreen *screen)
 {
+  gboolean is_composited;
   g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
 
-  return FALSE;
+  /* On Windows 8 and later, DWM (composition) is always enabled */
+  if (_is_win8_or_later)
+    return TRUE;
+  else
+    {
+      if (DwmIsCompositionEnabled (&is_composited) != S_OK)
+        return FALSE;
+      return is_composited;
+    }
 }
 
 static void